package com.example.sample.logic.fsm.base;

public abstract class FSMState {

    protected FSMManager manager;

    void attachManager(FSMManager manager){
        this.manager = manager;
    }

    @Override
    public String toString() {
        return this.getClass().getSimpleName();
    }

    public void changeState(int state){
        if (manager != null){
            manager.changeState(state);
        }
    }

    /**
     * 每个状态对应一个值
     */
    abstract protected int getStateValue();

    /**
     * 状态激活后的初始操作
     */
    abstract protected void onActive();

    /**
     * 对外部事件的响应
     */
    abstract protected void handleEvt(FSMEvt evt);
}
